package com.cqjtu.store.config;

import com.cqjtu.store.interceptors.TokenHandlerInterceptor;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ProjectName: cqjtu-store
 * @Titile: StoreWebmvcConfig
 * @Author: Lucky
 * @Description: mvc配置类
 */
@SpringBootConfiguration
public class StoreWebmvcConfig implements WebMvcConfigurer {
    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenHandlerInterceptor())
                .addPathPatterns("/user/**","/api/**") //添加；拦截url
                .excludePathPatterns("/user/login","/user/reg",
                        "/api/category/**",
                        "/api/product/**",   //放行商品模块下所有接口
                        "/api/order/getTotalInTime",
                        "/user/getAllUser",
                        "/api/order/getUserOrder/**",
                        "/api/order/getUserAndProductOrder/**",
                        "/api/order/getProductOrder/**",
                        "/api/order/getAllOrder",
                        "/api/order/getOrderByKey",
                        "/api/order/deleteOrder/**",
                        "/api/order/getRealTimeNum/**",
                        "/api/order/getAllOrderNum"
                )
                .excludePathPatterns("/admin/**"); //放行url
    }
}
